package com.pxene.dmp.test.mr.matchUser2;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.Tool;

public class MatchUser2Task2 extends Configuration implements Tool {

	@Override
	public void setConf(Configuration conf) {
		// TODO Auto-generated method stub

	}

	@Override
	public Configuration getConf() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int run(String[] args) throws Exception {
		Configuration conf = new Configuration();
		conf.set("mapreduce.job.queuename", "root.vendor.ven3"); // 设置队列
		Job job = Job.getInstance(conf);

		job.setJobName("secodeFilter");
		job.setJarByClass(MatchUser2Task2.class);

		job.setMapperClass(MatchUser2Mapper.class);
		job.setReducerClass(MatchUer2Reducer.class);

		job.setMapOutputKeyClass(Text.class);
		job.setMapOutputValueClass(Text.class);

		job.setOutputKeyClass(Text.class);
		job.setOutputValueClass(Text.class);
		String codePath = "/user/vendorwins/chenjinghui/word/autocode/";
		String wordsPath = "/user/vendorwins/chenjinghui/word/searchWord/";
		String bbspath = "/user/vendorwins/chenjinghui/word/bbsid/";
		FileInputFormat.addInputPaths(job, codePath);
		FileInputFormat.addInputPaths(job, wordsPath);
		FileInputFormat.addInputPaths(job, bbspath);

		Path out = new Path("/user/vendorwins/chenjinghui/secondFilter");
		FileOutputFormat.setOutputPath(job, out);
		FileSystem fs = FileSystem.get(conf);
		if (fs.exists(out)) {
			fs.delete(out, true);
		}
		return job.waitForCompletion(true) == true ? 0 : 1;
	}
}